package cn.db101.api.complex.component

import com.alibaba.csp.sentinel.slots.block.RuleConstant
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager
import org.intellij.lang.annotations.Flow
import org.springframework.boot.CommandLineRunner
import org.springframework.stereotype.Component


/**
 * @author zooy
 * @since 2024/11/15-16:03
 */
@Component
class StartSetting: CommandLineRunner {

    override fun run(vararg args: String?) {

        // 初始化限流规则
        FlowRuleManager.loadRules(listOf(FlowRule().also {
           it.refResource = "xinZhiWeather"
            it.count = 20.0
            it.grade = RuleConstant.FLOW_GRADE_QPS
        }, FlowRule().also {
            it.refResource = "gaoDeWeather"
            it.count = 20.0
            it.grade = RuleConstant.FLOW_GRADE_QPS
        }))
    }

}
